package com.gxc.controller;

import com.github.pagehelper.PageInfo;
import com.gxc.entity.ItemSku;
import com.gxc.service.ItemSkuService;
import javax.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * ItemSkuController.
 *
 * @author 宫新程
 * @since 2019/2/13 19:27
 */
@RestController
public class ItemSkuController {

  @Resource ItemSkuService itemSkuService;

  /** 分页查询. */
  @GetMapping("/mybatis/findAll/{pageNum}/{pageSize}")
  public PageInfo<ItemSku> mybatisFindAll(
      @PathVariable Integer pageNum, @PathVariable Integer pageSize) {
    if (pageNum == null || pageNum <= 0) {
      pageNum = 1;
    }
    if (pageSize <= 0) {
      pageSize = 10;
    }
    return itemSkuService.myBatisFindAll(pageNum, pageSize);
  }

  /** 分页查询. */
  @GetMapping("/jpa/findAll/{pageNum}/{pageSize}")
  public Page<ItemSku> jpaFindAll(
      @PathVariable Integer pageNum, @PathVariable Integer pageSize) {
    if (pageNum == null || pageNum <= 0) {
      pageNum = 1;
    }
    if (pageSize <= 0) {
      pageSize = 10;
    }
    return itemSkuService.jpaFindAll(pageNum, pageSize);
  }
}
